<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/static/js/dev.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>导航资源视图</title>
</head>
<body class="skin-default">

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <!--视图块-->
            <div class="container-fluid card">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--检索栏-->
                        <form class="form-inline search-bar" id="pageForm">
                            <div class="form-group">
                                <label class="control-label">资源名称：&nbsp;</label>
                                <input type="text" name="name" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">资源类型：&nbsp;</label>
                                <select name="type" class="form-control">
                                    <option value=""></option>
                                    <option value="1">导航资源</option>
                                    <option value="2">普通页面</option>
                                    <option value="3">逻辑资源</option>
                                    <option value="4">URI地址</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="control-label">归属项目：&nbsp;</label>
                                <select name="app" class="form-control">
                                    <option value=""></option>
                                </select>
                            </div>
                            <button type="button" class="btn btn-primary" onclick="joView.select()"> <i class="fa fa-search" aria-hidden="true"></i>&nbsp;查询</button>
                        </form>
                        <!--/检索栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--按钮栏-->
                        <div class="form-group button-bar">
                            <button isShow="" type="button" class="btn btn-primary" onclick="joView.add()">
                                <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;新增
                            </button>
                            <button type="button" class="btn btn-danger" onclick="joView.del()">
                                <i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;删除
                            </button>
                            <button type="button" class="btn btn-warning" onclick="window.location.reload()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                            </button>
                        </div>
                        <!--/按钮栏-->
                        <div style="line-height: 1.7;padding-top: 5px;" class="font-red">
                            说明：资源类型分为3种：
                            1.导航资源：菜单类型资源，通常用来做菜单;
                            2.普通页面：除了菜单外，系统内的其他页面都属于此范畴，普通页面一般不需要在此记录，如果有权限（例如：按钮权限）相关需求，可以在此处配置;
                            3.逻辑资源：系统内提供的任何东西都可以称作逻辑资源，通常不需要此配置；
                            4.URI地址：网关接口资源，导航资源只能做到展示控制，通过URI可以做到实际的访问控制；
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4 col-md-3 col-lg-3">
                        <ul class="ztree" id="navigateTree"></ul>
                    </div>
                    <div class="col-sm-8 col-md-9 col-lg-9">
                        <div class="table-bar">
                            <!--grid-->
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover" id="mainList" dataUrl="{URL_UMS}ums/navigate/getPage" deleteUrl="{URL_UMS}ums/navigate/delete" formUrl="/page/ums/navigateForm.html">
                                    <col field="icon_show" title="" width="40px" align="center"/>
                                    <col field="name" title="资源名称" width="20%" align="" event="click" />
                                    <col field="href" title="链接" width="30%" align=""  />
                                    <col field="remark" title="说明" width="25%" align=""  />
                                    <col field="num" title="显示顺序" width="15%" align=""  />
                                </table>
                            </div>
                            <!--/grid-->

                            <!--分页条-->
                            <div class="page-bar" gridId="mainList">

                            </div>
                            <!--/分页条-->
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<style>
    html,body{
        height: 100%;
    }
</style>
<script type="text/javascript">
    //高度适配
    function heightAdapt(){
        var h = $('body').height() - $(".card>.row:eq(0)").outerHeight() - $(".card>.row:eq(1)").outerHeight() - 60;
        if(h > 300){//避免高度过于小
            $(".table-bar").css('height', h+'px').css('overflow', 'auto');
            $("#navigateTree").css('height', h+'px').css('overflow', 'auto');
        }else{//默认高度为auto
            $(".table-bar").css('height', 'auto').css('overflow', 'auto');
            $("#navigateTree").css('height', 'auto').css('overflow', 'auto');
        }
    }

    window.onresize = function(){
        heightAdapt();
    };
    heightAdapt();

    layui.laydate.render({
        elem: '#createTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#createTime2' //注册日期控件
    });
    layui.laydate.render({
        elem: '#updateTime' //注册日期控件
    });
    layui.laydate.render({
        elem: '#updateTime2' //注册日期控件
    });
    $(function(){
        createNavigateTree('navigateTree', function(event, treeId, treeNode){
            if(treeNode.ID != "ROOT"){
                joView.setTransferParam("navId="+treeNode.id+"&navName="+treeNode.name);
            }else{
                joView.setTransferParam("");
            }
            joView.putQueryParam('parentId', treeNode.id);
            joView.select();//查询
        });
        joView.init({grid:$("#mainList"),PKName:"id",formWidth:'900px'});//初始化页面
    });
    //表格渲染时行处理,参数1为当前行的数据对象,参数2为当前行的索引值(最小为0)
    joView.handleItem = function(oItem,iIndex){
        oItem.icon_show = '<i title="'+oItem.icon+'" class="fa '+oItem.icon+'" aria-hidden="true"></i>';
        oItem.type = formatNavigateType(oItem.type);
    };
    //表格渲染完成后的回调,参数为表格数据(数组对象)
    joView.setGridDataAfter = function(oList){

    };
    //格式化资源类型
    function formatNavigateType(type){
        if(type == '1'){
            return '<span class="label label-primary">导航资源</span>';
        }else if(type == '2'){
            return '<span class="label label-info">普通页面</span>';
        }else if(type == '3'){
            return '<span class="label label-warning">逻辑资源</span>';
        }else{
            return type;
        }
    }
    /* 关于joView更多回调函数和配置参数可查看jo-page-view.js */
</script>
</body>
</html>
